<!DOCTYPE html>
<html lang="en">
<head>
    <title>专户单据</title>
    <#include "../inc/header.ftl"/>
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <div class="row">
                    <div id="grid-main-data" class="col-xs-12">
                        <table id="MainGrid" style="min-height: 500px"></table>
                        <div id="toolbar">
                            <div style="padding:8px">
                                单据号：<input id="billnumfind" class="easyui-textbox" style="width:140px">&emsp;
                                交易流水号：<input id="bankaffirmfind" class="easyui-textbox" style="width:140px">&emsp;
                                账户：<input id="bankidfind">
                                交易日期：<input id="paybankdtfind" class="easyui-datebox" style="width:140px">&emsp;
                                <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton" iconCls="icon-search">查 询</a>
                            </div>
                            <div style="padding:8px 8px 4px">
                                <a href="#" class="easyui-linkbutton" iconCls="icon-redo"
                                   onclick="javascript:sendInfo(1)">发送</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-back"
                                   onclick="javascript:sendInfo(2)">冲销</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-print"
                                   onclick="javascript:exportInfo()">导出</a>
                            </div>
                        </div>
                    </div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
            <!-- 发送复核 -->
            <#include "../inc/fuhe.ftl"/>

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>

<!-- inline scripts related to this page -->
<script type="text/javascript">

    jQuery(function ($) {
        $('#MainGrid').datagrid({
            url: prefix + '/bill/special/listSpecial',
            checkbox:true,
            pagination: true,
            fitColumns: false,
            striped: true,
            singleSelect: false,
            loadMsg: "正在努力加载数据，请稍后...",
            queryParams: {},
            columns: [[
                {field: 'ck', checkbox: true},
                {title: '单据号', field: 'billnum', width: 100},
                {title: '区划编码名称', field: 'cantonname', width: 100},
                {title: '预算级次', field: 'payeelevel', width: 100},
                {title: '收款户名', field: 'payeeunitname', width: 150},
                {title: '收款银行账号 ', field: 'payeebankaccount', width: 150},
                {title: '收款银行开户行', field: 'payeebankname', width: 150},
                {title: '项目编码名称', field: 'itemname', width: 100},
                {title: '金额', field: 'itemmoney1', width: 100},
                {title: '收款时间', field: 'paybankdt', width: 140},
                {title: '付款户名', field: 'payeraccountname', width: 150},
                {title: '付款银行账号', field: 'payeraccountcode', width: 150},
                {title: '付款银行开户行', field: 'payerbankname', width: 150},
                {title: '收款网点', field: 'bankstation', width: 130},
                {title: '交易流水号', field: 'bankaffirm', width: 140},
            ]],
            toolbar: '#toolbar',
            onBeforeLoad: function (param) {
                // 首次打开时，不加载数据
                var firstLoad = $(this).attr("firstLoad");  
                if (firstLoad == "false" || typeof (firstLoad) == "undefined") {  
                    $(this).attr("firstLoad","true");  
                    return false;  
                }  
                return true;  
            },
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    $('#grid-main-data').find('.datagrid-body').html('<div style="text-align: center;font-size: 14px;padding: 20px 0;">查询无数据</div>');
                }
            }
        });
        $(window).resize(function () {
            $('#MainGrid').datagrid('resize');
        });
        // 查询的下拉框
        $('#bankidfind').combogrid({
            panelWidth:550,
            idField:'bankid',
            textField:'accountcode',
            data: _bankdata,
            columns:[[
                {field: 'ck', checkbox: true},
                {field:'cantonname',title:'区划',width:80},
                {field:'accountcode',title:'账号',width:160},
                {field:'bankname',title:'开户行名称',width:260}
            ]]
        });
    });

    function searchInfo() {
        if ($('#bankidfind').val() == '') {
            $.messager.alert('提示', '请选择收款账户', 'info');
            return;
        }
        $('#MainGrid').datagrid('load', {
            payerbankid: $('#bankidfind').val(),
            paybankdt: $('#paybankdtfind').val(),
            bankaffirm: $('#bankaffirmfind').val(),
            billnum: $('#billnumfind').val()
        });
    }

    //发送/冲销
            function sendInfo(opt) {
                if(opt==1){
                    send_tit = "发送";
                    send_url = "/bill/special/sendSpecial";
                    send_reload = 0;
                }else{
                    send_tit = "冲销";
                    send_url = "/bill/special/cleanSpecial";
                    send_reload = 1;
                }
                openSendBox()
                var row = $('#SendMainGrid').datagrid('getData');
                $.each(row.rows,function(index, value) {
                    value.billid = value.payid
                });
            }

    function exportInfo() {
                var bankid = $('#bankidfind').val();
                if (bankid == '') {
                    $.messager.alert('提示', '请选择收款账户', 'info');
                    return;
                }
                var paybankdt = $('#paybankdtfind').val();
                if (paybankdt == '') {
                    $.messager.alert('提示', '请选择收款日期', 'info');
                    return;
                }
        var downurl = prefix + '/bill/special/specialExport?bankid=' + bankid + '&paybankdt=' + paybankdt;
        window.location.href = downurl;
    }


</script>
</body>
</html>
